# -*- makefile -*-

# The contents of this file are subject to the MonetDB Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.monetdb.org/Legal/MonetDBLicense
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is the MonetDB Database System.
#
# The Initial Developer of the Original Code is CWI.
# Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
# Copyright August 2008-2014 MonetDB B.V.
# All Rights Reserved.

# make rules to generate MonetDB RPMs (works on Fedora, only)

rpmtopdir = $(shell cd $(top_builddir) && pwd)/rpmbuild

RPMBUILDARGS = --define="_tmppath /tmp" --define="_topdir $(rpmtopdir)" --define="tmpdir %{_tmppath}" --define="rpmcflags -O2 " --define="packager MonetDB Database System <info@monetdb.org>" --define="oid@oids@ 1"

$(top_builddir)/$(distdir).tar.bz2:
	$(MAKE) $(AM_MAKEFLAGS) dist

$(rpmtopdir)/rpmmacros:
	mkdir -p $(rpmtopdir)/RPMS
	mkdir -p $(rpmtopdir)/SRPMS
	mkdir -p $(rpmtopdir)/SPECS
	mkdir -p $(rpmtopdir)/BUILD
	mkdir -p $(rpmtopdir)/INSTALL

rpm: MonetDB.spec $(top_builddir)/$(distdir).tar.bz2 $(rpmtopdir)/rpmmacros
	$(RPMBUILD) $(RPMBUILDARGS) --define="dist _@LINUX_DIST@" -ta --target `uname -m` --define="comp_cc @CC@" $(top_builddir)/$(distdir).tar.bz2

srpm: MonetDB.spec $(top_builddir)/$(distdir).tar.bz2 $(rpmtopdir)/rpmmacros
	$(RPMBUILD) $(RPMBUILDARGS) --define="dist %{?undefined}" -ts $(top_builddir)/$(distdir).tar.bz2
